package org.example.movies.service.impl;


import org.example.movies.dao.IUserDao;
import org.example.movies.dao.impl.UserDaoImpl;
import org.example.movies.pojo.TUser;
import org.example.movies.service.IUserService;

import java.util.List;

public class UserServiceImpl implements IUserService {
    private IUserDao userDao=new UserDaoImpl();
    @Override
    public boolean checkUser(TUser user) {
        List<TUser> list = userDao.checkUser();
        for (TUser tUser:list) {
            if (tUser.getUsername().equals(user.getUsername())&&tUser.getPassword().equals(user.getPassword())){
                return true;
            }
        }
        return false;
    }

    @Override
    public boolean checkName(String username) {
        List<TUser> list = userDao.checkUser();
        for (TUser user:list) {
            if (user.getUsername().equals(username)){
                return true;
            }
        }
        return false;
    }

    @Override
    public int insertUser(TUser user) {
        return userDao.insertUser(user);
    }
}
